﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Issue.aspx.cs" Inherits="RichECMS.ServerPages.Issue.Issue" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../../sysCommon/sysStyle/Pages.css" type="text/css" rel="stylesheet" />
    <link href="../../sysCommon/sysStyle/style.css" type="text/css" rel="stylesheet" />
   <link href="../../sysCommon/sysScripts/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"
        type="text/css" />
    <link href="../../sysCommon/sysScripts/ztree/css/Filetree.css" rel="stylesheet" type="text/css" />
    <script src="../../sysCommon/sysScripts/jquery/1.7.2/Jquery.js" type="text/javascript"></script>
    <script src="../../sysCommon/sysScripts/ztree/js/jquery.ztree.all-3.3.min.js" type="text/javascript"></script>
    <script src="../../sysCommon/sysScripts/parent1.js" type="text/javascript"></script>
    <script src="../../sysCommon/sysScripts/commompage.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#ibtnIssue").click(function () {
                alerttispage('正在发布，请稍候...');
            });
            $(".Issueabtn").bind("click", function () {
                var index = $(".Issueabtn").index(this);
                $(".task_list").hide();
                $(".task_list").eq(index).show();
                $(".Issueabtn").css("color", "black");
                $(this).css("color", "green");
                return false;
            })
        })
    </script>
     <script type="text/javascript">
		<!--
        var setting = {
            check: {
				enable: true
				//chkboxType: {"Y":"Ps", "N":"Ps"}
			},
            view: {
				selectedMulti: false
			},
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback: {
                beforeClick: beforeClick,
                onCheck: onCheck
            }
        };

         var setting2 = {
            data: {
                simpleData: {
                    enable: true
                }
            }
        };

        var zNodes = <% =BuildSectionTree() %>;
        var zNodes2source = [];
        var zNodes2=zNodes2source;

        function beforeClick(treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("treeSection");
			zTree.checkNode(treeNode, !treeNode.checked, null, true);
			return false;
		}

        var zTree;

        function onCheck(e, treeId, treeNode) {
                //轮询所有选中的根节点
                zTree = $.fn.zTree.getZTreeObj("treeSection");
                var nodes = zTree.getNodes();
			    var v = "",
                vhidden="";
                
                for (var i=0;i<nodes.length; i++) {
                    if(nodes[i].checked==true)
                    {
                           v+=buildNodes(nodes[i])+",";
                           vhidden+=buildNodesSid(nodes[i]);
                    }
			    }
                 if (v.length > 0 ) v = v.substring(0, v.length-1);
			     $("#selectSectionvalue").val(v);
                 if (vhidden.length > 0 ) vhidden = vhidden.substring(0, vhidden.length-1);
                  $("#sectionCurrentSelect").val(vhidden);
                 var tempodes=jQuery.parseJSON("["+v+"]");
                
                 $.fn.zTree.init($("#selectTreeSelected"), setting2, tempodes);
        }
        
        function buildNodes(currentnode) {
            if(currentnode.checked!=true)
            {
                return "";
            }
            var tempnode = "{";
            var tempone='"name":'+'"'+currentnode.name+'",';

            if(currentnode.children!=null)
            {
                if(currentnode.children.length>0)
                {
                    var tt="";
                    for(var i=0;i<currentnode.children.length;i++)
                    {
                        if(currentnode.children[i].checked==true)
                        {
                             tt+=buildNodes(currentnode.children[i])+",";
                        }
                    }
                    if (tt.length > 0 ) tt = tt.substring(0, tt.length-1);
                   tempone+='"children":['+tt+'],';
                }
            }

            tempone+='"isParent":'+currentnode.isParent+',';
            tempone+='"open":'+currentnode.open+',';
            tempone+='"lifetype":'+'"'+currentnode.lifetype+'",';
           
             tempone+='"sid":'+'"'+currentnode.sid+'"';
             tempnode +=tempone+ "}";

             return tempnode;
        }

         function buildNodesSid(currentnode) {
            if(currentnode.checked!=true)
            {
                return "";
            }
            var tempsid = currentnode.sid+",";
            if(currentnode.children!=null)
            {
                if(currentnode.children.length>0)
                {
                    var tt="";
                    for(var i=0;i<currentnode.children.length;i++)
                    {
                        if(currentnode.children[i].checked==true)
                        {
                             tt+=buildNodesSid(currentnode.children[i]);
                        }
                    }
                   tempsid+=tt;
                }
            }

             return tempsid;
        }

        function updateNode(newNodes) {
			var zTree = $.fn.zTree.getZTreeObj("selectTreeSelected"),
			nodes = newNodes;console.dir(zTree);
			if (nodes.length == 0) {
				alert("请先选择栏目");
			}
			for (var i=0, l=nodes.length; i<l; i++) {
				zTree.updateNode(nodes[i]);
			}
		}

        function showMenu() {
			var cityObj = $("#selectSection");
			var cityOffset = $("#selectSection").offset();
			$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
			$("body").bind("mousedown", onBodyDown);
		}
		function hideMenu() {
			$("#menuContent").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
		}
		function onBodyDown(event) {
			if (!(event.target.id == "menuBtn" || event.target.id == "selectSection" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
				hideMenu();
			}
		}

        $(document).ready(function () {
        //判断ie浏览器
            if(!+[1,])
            {
                var pIeJs=document.createElement("script"); 
                pIeJs.src='../../sysCommon/sysScripts/lib/json2.js';
                document.appendChild(pIeJs);
            };

            $.fn.zTree.init($("#treeSection"), setting, zNodes);
            $.fn.zTree.init($("#selectTreeSelected"), setting2, zNodes2);
        });
		//-->
    </script>
    <style type="text/css">
        a.Issueabtn
        {
            margin: 0px 10px;
            border: 0px solid #ccc;
            padding: 3px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="main_body">
        <!--=====================================================================-->
        <div class="right_body">
            <div class="right_top">
                <a href="#">CMS内容管理平台</a>><span style="color: #417DB7">网站发布</span></div>
            <div class="title">
                <div class="information">
                    网站发布：<span><a class="Issueabtn" href="#" style="color:Green;">快速发布</a><a class="Issueabtn" href="#">按栏目发布</a></span>
                </div>
            </div>
            <div class="rele_box">
                <div class="re_task">
                    <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="task_title">
                                待发布任务：
                            </td>
                            <td class="task_con">
                                <ul>
                                    <li>首页更新</li>
                                    <li><span style="color: #F00; font-weight: bold">
                                        <asp:Label ID="labNoIssueS" runat="server" Text=""></asp:Label></span>个栏目需要更新</li>
                                    <li><span style="color: #F00; font-weight: bold">
                                        <asp:Label ID="labNoIssueA" runat="server" Text=""></asp:Label></span>篇文章需要更新</li>
                                </ul>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="task_list">
                <table width="360" border="0" align="left" cellpadding="0" cellspacing="0">
                    <tr>
                        <td align="center" valign="middle" height="30" width="30">
                            <asp:RadioButton ID="rbtnIssueIndex" runat="server" Checked="true" />
                        </td>
                        <td align="left" valign="middle" width="150">
                            发布首页
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td align="center" valign="middle" height="30" width="30">
                            <asp:RadioButton ID="rbtnIssueST" runat="server" GroupName="a" Checked="true" />
                        </td>
                        <td align="left" valign="middle" width="150">
                            只发布<span style="color: #F00; font-weight: bold"><asp:Label ID="labNoIssueS2" runat="server"
                                Text=""></asp:Label></span>个栏目
                        </td>
                        <td align="center" valign="middle" height="30" width="30">
                            <asp:RadioButton ID="rbtnIssueSTAll" runat="server" GroupName="a" />
                        </td>
                        <td align="left" valign="middle" width="150">
                            重新发布所有栏目<span style="color: #F00; font-weight: bold"><asp:Label ID="labIssueS2" runat="server"
                                Text=""></asp:Label></span>个
                        </td>
                    </tr>
                    <tr>
                        <td align="center" valign="middle" height="30" width="30">
                            <asp:RadioButton ID="rbtnIssueAT" runat="server" GroupName="b" Checked="true" />
                        </td>
                        <td align="left" valign="middle" width="150">
                            只发布<span style="color: #F00; font-weight: bold"><asp:Label ID="labNoIssueA2" runat="server"
                                Text=""></asp:Label></span>篇文章
                        </td>
                        <td align="center" valign="middle" height="30" width="30">
                            <asp:RadioButton ID="rbtnIssueATAll" runat="server" GroupName="b" />
                        </td>
                        <td align="left" valign="middle" width="150">
                            重新发布所有文章<span style="color: #F00; font-weight: bold"><asp:Label ID="labIssueA2" runat="server"
                                Text=""></asp:Label></span>篇
                        </td>
                    </tr>
                    <tr>
                        <td align="center" valign="middle" height="40" width="30">
                        </td>
                        <td align="left" valign="middle" width="150">
                            <asp:ImageButton ID="ibtnIssue" runat="server" ImageUrl="../../sysCommon/sysImages/release.jpg"
                                alt="发布" Width="87" Height="27" OnClick="ibtnIssue_Click" />
                        </td>
                        <td align="center" valign="middle" height="40" width="30">
                        </td>
                        <td align="left" valign="middle" width="150">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </div>
            <div class="task_list" style="display: none;">
                <table width="600" border="0" align="left" cellpadding="0" cellspacing="0">
                    <tr>
                        <td align="center" align="right"; valign="top" height="30" width="90">
                            选择要发布的栏目： <br />
                            已选栏目：
                        </td>
                        <td align="left" valign="middle" width="150">
                            <div class="zTreeDemoBackground left">
                                <input id="selectSection" type="text" class="sectioninput" readonly="readonly" value=""
                                    onclick="showMenu();" /><a id="menuBtn" href="#" onclick="showMenu(); return false;">选择栏目</a>
                                <br />
                                <div style="height: 190px; width: 190px; margin: 5px 0px 5px 0px; overflow-x: hidden;
                                    overflow-y: auto; background-color: #fff;">
                                    <ul id="selectTreeSelected" class="ztree" style="margin-top: 0; width: 190px; height: 180px;">
                                    </ul>
                                </div>
                                <textarea id="selectSectionvalue" runat="server" name="selectSectionvalue" style="display: none;">
                                                        </textarea>
                                <asp:HiddenField ID="sectionCurrentSelect" runat="server" />
                            </div>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td align="center" valign="middle" height="40" width="30">
                        </td>
                        <td align="left" valign="middle" width="150">
                            <asp:ImageButton ID="ibtnIssueSection" runat="server" ImageUrl="../../sysCommon/sysImages/release.jpg"
                                alt="发布" Width="87" Height="27" OnClick="ibtnIssue_Click" />
                        </td>
                        <td align="center" valign="middle" height="40" width="30">
                        </td>
                        <td align="left" valign="middle" width="150">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
